﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Spanner
{
    public partial class UI
    {
        /// <summary>
        /// The typed undefined value.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static Expr<T> Undefined<T>()
        {
            return JSExpr<T>("undefined");
        }

        /// <summary>
        /// ToString(e) is equivalent to the JavaScript (e).toString().
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="x"></param>
        /// <returns></returns>
        public static Expr<string> ToString<T>(Expr<T> x)
        {
            return JSExpr<string>("#.toString()", x);
        }

        public static Expr<string> DecodeUri(Expr<string> x)
        {
            return JSExpr<string>("decodeURI(#)", x);
        }

        public static Expr<string> DecodeUriComponent(Expr<string> x)
        {
            return JSExpr<string>("decodeURIComponent(#)", x);
        }

        public static Expr<string> EncodeUri(Expr<string> x)
        {
            return JSExpr<string>("encodeURI(#)", x);
        }

        public static Expr<string> EncodeUriComponent(Expr<string> x)
        {
            return JSExpr<string>("encodeURIComponent(#)", x);
        }

        public static Expr<string> Escape(Expr<string> x)
        {
            return JSExpr<string>("escape(#)", x);
        }

        public static Expr<string> Unescape(Expr<string> x)
        {
            return JSExpr<string>("unescape(#)", x);
        }
    }
}
